import json

try:
    with open('/data/whl/cl/gpt2/dataset/16.txt', 'r', encoding='utf-8') as f:
        lines = f.readlines() 
except FileNotFoundError:
    print("无法找到语料文件'data.txt'，请检查文件是否存在。")


train_datas = []
temp_data = ''

for line in lines:
    if line != '\n':
        line = line.strip() 
        temp_data += (line + '\t') 
    else:
        train_datas.append(temp_data)
        temp_data = ''

with open('/data/whl/cl/gpt2/dataset/16_dataset.txt', 'w', encoding='utf-8') as f:
    for train_data in train_datas:
        f.write(train_data + '\n') 

    
    